home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-06-23 | 2.1 KB | 88 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.awt.*;
- import java.io.IOException;
- import java.io.File;
- import java.awt.event.*;
-
- import quicktime.*;
- import quicktime.app.QTFactory;
- import quicktime.io.QTFile;
- import quicktime.util.*;
-
- import duke.*;
- /**
- * Moving Movie Demo.
- */
- public class DukeMovie extends Frame {
- //_________________________ CLASS VARIABLES
- private static final Color bgColor = Color.lightGray; //tumbling duke gif's are light gray
-
- //_________________________ CLASS METHODS
- public static void main(String args[]) {
- try {
- QTSession.open(); //start a QuickTime session
- Frame f = new DukeMovie("Biscotti = Java + QuickTime");
- f.show();
- f.toFront();
- }
- catch (Exception e) {
- QTSession.close();
- System.exit(0);
- }
- }
-
- DukeMovie (String frameTitle) throws QTException, IOException {
- super (frameTitle);
-
- setBackground(bgColor);
- setLayout(new BorderLayout());
-
- ms = new MovieScreen();
- add("Center", ms.getCanvas());
-
- // create, add and start tumbling duke, if the images are available
- try {
- File file = QTFactory.findAbsolutePath ("duke");
- duke = new TumbleItem(file.getAbsolutePath());
- } catch (Exception e) {
- e.printStackTrace();
- }
- if (duke != null) {
- duke.setBackground(bgColor);
- add("North", duke);
- }
-
- // create our little control panel out of simple AWT objects
- cp = new ControlPanel(bgColor, ms);
- add("South", cp);
-
- setBounds(0, 0, 625, 420);
- addWindowListener(new WindowAdapter () {
- public void windowOpened (WindowEvent ev) {
- if (duke != null) duke.start();
- }
-
- public void windowClosing (WindowEvent e) {
- if (duke != null) duke.stop();
- QTSession.close();
- dispose();
- }
-
- public void windowClosed (WindowEvent e) {
- System.exit(0);
- }
- });
- }
-
- //_________________________ INSTANCE VARIABLES
- private MovieScreen ms;
- private TumbleItem duke;
- private ControlPanel cp;
- }
-